:root {
    --primary-color: #4a90e2;
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 60px;
    --transition-speed: 0.3s;
}

/* 主题颜色 */
.light-theme {
    --bg-color: #f5f6fa;
    --sidebar-bg: #ffffff;
    --text-color: #2c3e50;
    --card-bg: #ffffff;
    --border-color: #eaeaea;
    --hover-color: rgba(74, 144, 226, 0.15);
}

.dark-theme {
    --bg-color: #1a1a1a;
    --sidebar-bg: #2c2c2c;
    --text-color: #ffffff;
    --card-bg: #333333;
    --border-color: #404040;
    --hover-color: rgba(74, 144, 226, 0.15);
}

/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color var(--transition-speed);
}

.container {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏样式 */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    transition: all var(--transition-speed);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .menu-item span,
.sidebar.collapsed .submenu,
.sidebar.collapsed .submenu-arrow {
    display: none;
}

.sidebar.collapsed .menu-item {
    padding: 0.8rem;
    justify-content: center;
}

.sidebar.collapsed .menu-item i:not(.submenu-arrow) {
    margin: 0;
    font-size: 1.2rem;
}

.sidebar-header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.toggle-sidebar {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    font-size: 1.2rem;
}

.menu {
    padding: 1rem 0;
}

.menu-category {
    margin: 0.5rem 0;
    position: relative;
}

.menu-item {
    padding: 0.8rem 1rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 6px;
    margin: 0 0.5rem;
    position: relative;
}

.menu-item:hover {
    background-color: rgba(74, 144, 226, 0.1);
}

.menu-item.active {
    background-color: rgba(74, 144, 226, 0.15);
    color: var(--primary-color);
    font-weight: 500;
}

.menu-item i:not(.submenu-arrow) {
    margin-right: 0.8rem;
    width: 20px;
    text-align: center;
}

.submenu-arrow {
    transition: transform 0.3s;
    font-size: 0.8rem;
    opacity: 0.6;
    width: 20px !important;
    margin-left: 0.5rem !important;
}

.menu-category.active .submenu-arrow {
    transform: rotate(180deg);
    opacity: 1;
}

.submenu {
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: rgba(74, 144, 226, 0.03);
    margin: 0 0.5rem;
    border-radius: 6px;
    opacity: 0;
    visibility: hidden;
}

.menu-category.active .submenu {
    max-height: 1000px;
    margin-top: 0.5rem;
    padding: 0.5rem 0;
    opacity: 1;
    visibility: visible;
}

.submenu-item {
    padding: 0.6rem 1rem 0.6rem 2.8rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9rem;
    border-radius: 4px;
    margin: 0.2rem 0.5rem;
    position: relative;
    color: var(--text-color);
    background-color: transparent;
}

.submenu-item:hover {
    background-color: var(--hover-color);
    color: var(--primary-color);
}

.submenu-item.active {
    background-color: var(--hover-color);
    color: var(--primary-color);
    font-weight: 500;
}

.submenu-item.active::before {
    display: none;
}

/* 内容区样式 */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-speed);
    padding-top: 64px;
}

.sidebar.collapsed + .content {
    margin-left: var(--sidebar-collapsed-width);
}

.content-wrapper {
    padding: 2rem;
}

/* 卡片样式 */
.category-section {
    margin-bottom: 3rem;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.category-title {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 1.5rem;
}

.subcategory {
    margin-bottom: 2rem;
}

.subcategory-title {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.link-card {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.3s;
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.link-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.link-card-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.link-card-header i {
    font-size: 1.2rem;
    color: var(--primary-color);
}

.link-card-header h4 {
    margin: 0;
    font-size: 1.1rem;
}

.link-description {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.8;
    line-height: 1.4;
}

/* 主题切换开关 */
.theme-switch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* 回到顶部按钮 */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--primary-color);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    transform: translateY(20px);
}

.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 64px;
        left: 0;
        height: calc(100vh - 64px);
        transform: translateX(-100%);
        width: 280px;
        z-index: 999;
        background-color: var(--sidebar-bg);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    }

    .sidebar.expanded {
        transform: translateX(0);
    }

    .content {
        margin-left: 0 !important;
        width: 100%;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 998;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
        width: 280px;
    }

    .links-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .fixed-header {
        padding: 0 16px;
    }

    .friend-link-btn span {
        display: none;
    }

    .friend-link-btn {
        width: 40px;
        padding: 0;
        justify-content: center;
    }

    .site-title {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 100%;
    }
}

/* 添加加载状态样式 */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    display: none;
}

.loading.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 优化滚动条样式 */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.content-wrapper::-webkit-scrollbar {
    width: 8px;
}

.content-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.content-wrapper::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

/* 固定顶部栏样式 */
.fixed-header {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    height: 64px;
    background-color: var(--card-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.site-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

/* 图标按钮通用样式 */
.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background-color: transparent;
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    background-color: var(--hover-color);
    color: var(--primary-color);
}

/* 友链按钮样式 */
.friend-link-btn {
    height: 40px;
    padding: 0 20px;
    border: none;
    border-radius: 10px;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.friend-link-btn:hover {
    background-color: var(--primary-color-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.25);
}

.friend-link-btn i {
    font-size: 1rem;
}

/* 主题切换按钮动画 */
.theme-toggle {
    overflow: hidden;
}

.theme-toggle i {
    transition: all 0.3s ease;
}

.dark-theme .theme-toggle i {
    transform: rotate(360deg);
}

.dark-theme .theme-toggle i.fa-sun::before {
    content: "\f186"; /* 月亮图标的 Unicode */
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
}

.modal-content {
    position: relative;
    background-color: var(--bg-color);
    margin: 15% auto;
    padding: 20px;
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.close-modal {
    position: absolute;
    right: 20px;
    top: 10px;
    font-size: 24px;
    cursor: pointer;
}

/* 表单样式 */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-color);
    color: var(--text-color);
}

.submit-btn {
    width: 100%;
    padding: 10px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.submit-btn:hover {
    background-color: var(--primary-color-dark);
}

/* 更新侧边栏切换按钮样式 */
.icon-btn.toggle-sidebar {
    position: relative;
    left: 0;
    top: 0;
    transform: none;
    z-index: 1001;
    background-color: transparent;
    border: none;
    border-radius: 10px;
}

.icon-btn.toggle-sidebar:hover {
    background-color: var(--hover-color);
    color: var(--primary-color);
}
